var AddManager = function() {

	// Form表单提交信息
	var fnEditCallback = function(data) {
		$("#saveBtn").button("reset");
		if (data.type == 'success') {
			BootstrapDialog.show({
				title : '提示',
				message : '数据保存成功',
				buttons : [ {
					label : '确定',
					cssClass : 'btn btn-sm btn-primary',
					action : function(dialogItself) {
						dialogItself.close();
						window.location.href = ctx + '/sysCompanyDivide/list.html';
					}
				} ]
			});
		} else {
			BootstrapDialog.show({
				type : BootstrapDialog.TYPE_WARNING,
				title : '警告',
				message : data.message,
				buttons : [ {
					label : '确定',
					cssClass : 'btn btn-sm btn-primary',
					action : function(dialogItself) {
						dialogItself.close();
					}
				} ]
			});
		}
	};

	return {
		/**
		 * 初始状态
		 */
		init : function() {
			this.initListener();
		},

		/**
		 * 监听开关事件
		 */
		initListener : function() {
			$("#saveBtn").click(function() {
				var form1 = $('#addOrEditForm');
				form1.validate({
					// 验证规则
					rules : {
						orderNo : {
							required : true
						},
						receiverMan : {
							required : true
						},
						receiverPhone : {
							required : true
						},
						receiverArea : {
							required : true
						},
						receiverAdress : {
							required : true
						}
					},
					messages : {
						orderNo : {
							required : "请输入投保单编号"
						},
						receiverMan : {
							required : "请输入收件人姓名"
						},
						receiverPhone : {
							required : "请输入收件人电话"
						},
						receiverArea : {
							required : "请选择收件人地址"
						},
						receiverAdress : {
							required : "请输入收件人详细地址"
						}
					},
				});
				if (form1.valid()) {
					var postData = $("#addOrEditForm").serializeJson();
					$.ajax({
						"dataType" : 'json', // 接受数据格式
						"type" : "POST", // 数据发送方式
						"data" : postData,
						"url" : ctx + "/sysCompanyDivide/edit", // 后台处理程序
						"success" : fnEditCallback
					});
				}
			});
			
			/**
			 * 返回
			 */
			$("#cancel").click(function() {
				window.location.href = ctx + '/sysCompanyDivide/list.html';
			});

		},
		
	};
}();

/*
 * Powered By [Code-Generator]
 * Web Site: http://www.solveanalysi.tech
 */
